package cn.hou.java.designpattern._18memento;

public class Test {
	
	public static void main(String[] args) {
		Person person = new Person("yaozhen","18");
		System.out.println(person);
		//备份,使用备忘录对象管理类
		MementoTaker mementoTaker = new MementoTaker();
		mementoTaker.setMemento(person.backup());
		//操作
		System.out.println("------------");
		person.setName("何毅");
		person.setAge("20");
		System.out.println(person);
		System.out.println("------------");
		//操作失误,还原
		person.rollBack(mementoTaker.getMemento());
		System.out.println(person);
	}

}
